In [1]:
# Requires GLPlot
using ApproxFun

Heat equation with Dirichlet $$u_t = \Delta u$$


In [2]:
# domain is a disk
d=Disk()
# initial condition
u0   = Fun((x,y)->exp(-40(x-.1)^2-40(y+.2)^2),d)
# dirichlet boundary conditions
B=dirichlet(d)

Δ=lap(d)
h=0.0001 # time step
timeevolution(B,Δ,ProductFun(u0),h)


The GLFW library is not initialized
while loading In[2], in expression starting on line 10

 in error at error.jl:21
 in anonymous at /Users/solver/.julia/v0.3/GLFW/src/GLFW.jl:27
 in ErrorCallbackWrapper at /Users/solver/.julia/v0.3/GLFW/src/util.jl:36
 in PollEvents at /Users/solver/.julia/v0.3/GLFW/src/glfw3.jl:419
 in glupdatewindow at /Users/solver/.julia/v0.3/ApproxFun/src/Plot/GLPlot.jl:35
 in glsurfupdate at /Users/solver/.julia/v0.3/ApproxFun/src/Plot/GLPlot.jl:53
 in plot at /Users/solver/.julia/v0.3/ApproxFun/src/Plot/Plot.jl:203
 in timeevolution at /Users/solver/.julia/v0.3/ApproxFun/src/Extras/timeevolution.jl:130
 in timeevolution at /Users/solver/.julia/v0.3/ApproxFun/src/Extras/timeevolution.jl:141
 in timeevolution at /Users/solver/.julia/v0.3/ApproxFun/src/Extras/timeevolution.jl:148

Wave equation with Dirichlet $$u_{tt} = \Delta u$$


In [3]:
# domain is a disk
d=Disk()

# initial condition
u0   = Fun((x,y)->exp(-50x^2-40(y-.1)^2)+.5exp(-30(x+.5)^2-40(y+.2)^2),d)

# dirichlet boundary conditions, try neumann(d).  mixed is also possible
B= dirichlet(d)   
Δ=lap(d)
h = 0.005

# the 2 specifies that we are solving a second order equation
# the default is to take u_t(x,0)=0
timeevolution(2,B,Δ,u0,h)


Warning: redefining constant volumeshader
Warning: redefining constant uvwshader
The GLFW library is not initialized
while loading In[3], in expression starting on line 14

 in error at error.jl:21
 in anonymous at /Users/solver/.julia/v0.3/GLFW/src/GLFW.jl:27
 in ErrorCallbackWrapper at /Users/solver/.julia/v0.3/GLFW/src/util.jl:36
 in PollEvents at /Users/solver/.julia/v0.3/GLFW/src/glfw3.jl:419
 in glupdatewindow at /Users/solver/.julia/v0.3/ApproxFun/src/Plot/GLPlot.jl:35
 in glsurfupdate at /Users/solver/.julia/v0.3/ApproxFun/src/Plot/GLPlot.jl:53
 in plot at /Users/solver/.julia/v0.3/ApproxFun/src/Plot/Plot.jl:203
 in timeevolution2 at /Users/solver/.julia/v0.3/ApproxFun/src/Extras/timeevolution.jl:166
 in timeevolution2 at /Users/solver/.julia/v0.3/ApproxFun/src/Extras/timeevolution.jl:205
 in timeevolution2 at /Users/solver/.julia/v0.3/ApproxFun/src/Extras/timeevolution.jl:215
 in timeevolution at /Users/solver/.julia/v0.3/ApproxFun/src/Extras/timeevolution.jl:217

Wave equation with Neumann $$u_{tt} = \Delta u, u(x,y,0)=u_0(x,y)$$


In [4]:
h    = 0.005
d=Disk()
# initial condition
u0   = Fun((x,y)->exp(-50x^2-40(y-.1)^2)+.5exp(-30(x+.5)^2-40(y+.2)^2),d)
B= neumann(d)

Δ=lap(d)

timeevolution(2,B,Δ,u0,h)


Warning: redefining constant volumeshader
Warning: redefining constant uvwshader
2015-07-06 10:32:18.746 julia[55320:592181] IMK Stall detected, *please Report* your user scenario in <rdar://problem/16792073> - (imkxpc_inputSessionDoneSleepWithReply:) block performed very slowly (3.54 secs)
The GLFW library is not initialized
while loading In[4], in expression starting on line 9

 in error at error.jl:21
 in anonymous at /Users/solver/.julia/v0.3/GLFW/src/GLFW.jl:27
 in ErrorCallbackWrapper at /Users/solver/.julia/v0.3/GLFW/src/util.jl:36
 in PollEvents at /Users/solver/.julia/v0.3/GLFW/src/glfw3.jl:419
 in glupdatewindow at /Users/solver/.julia/v0.3/ApproxFun/src/Plot/GLPlot.jl:35
 in glsurfupdate at /Users/solver/.julia/v0.3/ApproxFun/src/Plot/GLPlot.jl:53
 in plot at /Users/solver/.julia/v0.3/ApproxFun/src/Plot/Plot.jl:203
 in timeevolution2 at /Users/solver/.julia/v0.3/ApproxFun/src/Extras/timeevolution.jl:166
 in timeevolution2 at /Users/solver/.julia/v0.3/ApproxFun/src/Extras/timeevolution.jl:205
 in timeevolution2 at /Users/solver/.julia/v0.3/ApproxFun/src/Extras/timeevolution.jl:215
 in timeevolution at /Users/solver/.julia/v0.3/ApproxFun/src/Extras/timeevolution.jl:217

Klein–Gordon equation with Dirichlet $$u_{tt} = \Delta u - 100u, u(x,y,0)=u_0(x,y)$$


In [ ]:
d=Disk()
# initial condition
u0   = Fun((x,y)->exp(-50x^2-40(y-.1)^2)+.5exp(-30(x+.5)^2-40(y+.2)^2),d)
B= dirichlet(d) 

L=lap(d)-100I

h    = 0.005
timeevolution(2,B,L,u0,h)

Beam equation $$u_{tt} + \Delta^2 u = 0$$


In [ ]:
d=Disk()
# initial condition
u0   = Fun((x,y)->exp(-50x^2-40(y-.1)^2)+.5exp(-30(x+.5)^2-40(y+.2)^2),d)
B= [dirichlet(d) ,neumann(d)]

L=-lap(d)^2

h    = 0.0005
u4=timeevolution(2,B,L,u0,h);